﻿@model Post
<div class="post type-post article">
    <div class=" header">
        <div class="title">@Model.Title</div>
        <div class="info info1">
            <span class="time">@Model.Time.ToString()</span>
            @if (Html.IsAdmin())
            {
                <a href="javascript:DropEnable();$('.post-body').slideUp();$('.post-edit').slideDown();">编辑文章</a>
                <a href="javascript:$('#frmDeletePost').submit();">删除文章</a>
                <form id="frmDeletePost" asp-action="PostDelete" asp-controller="Admin" method="post" asp-route-id="@Model.Url"></form>                
                <form asp-action="PostEdit" asp-controller="Admin" method="post" id="frmSavePost"></form>
            }
            <span class="edit"></span>
        </div>
        <div class="info info2">
            <span class="tag">
                @if (Model.CatalogId != null)
                {
                    @("分类:")
                    <a asp-action="Catalog" asp-controller="Home" asp-route-id="@Model.Catalog.Url">@Model.Catalog.Title</a>
                }

                标签:
                @foreach (PostTag x in Model.Tags)
                {
                    <a asp-action="Tag" asp-controller="Home" asp-route-tag="@x.Tag">@x.Tag</a>
                }
            </span>
        </div>
    </div>
    <div class="section entry">
        <div class="post-body">
            @Html.Marked(Model.Content)
        </div>
        @if (Html.IsAdmin())
        {
            <div class="post-edit">
                <p><input id="txtTitle" type="text" placeholder="标题" value="@Model.Title" /></p>
                <p><input id="txtUrl" type="text" placeholder="URL" value="@Model.Url" /></p>
                <p>
                    <select id="lstCatalogs">
                        <option value="">未分类</option>
                        @foreach (CatalogViewModel c in ViewBag.Catalogs)
                        {
                                <!option value="@c.Id" @(Model.CatalogId == c.Id ? "selected" : "")>@c.Title</!option>
                        }
                    </select>
                </p>
                <p>
                    <div class="markdown-textbox-outer">
                        <textarea id="txtContent" class="markdown-textbox" name="Content" placeholder="Markdown here...">@(new HtmlString(Model.Content))</textarea>
                        <div class="markdown-textbox-bottom">拖拽文件、粘贴文件或<a href="javascript:uploadAttachment();">选择文件</a>以添加附件。</div>
                    </div>
                </p>
                <form id="frmAjaxUpload">
                    <input type="file" id="uploadFile" name="file" />
                </form>
                <p>
                    <input type="text" id="txtTags" placeholder="标签用,分隔" value="@Html.TagSerialize(Model.Tags)" />
                </p>
                <p>
                    <input type="checkbox" id="chkIsPage" @(Model.IsPage ? "checked" : "") /> 是否为页面
                </p>
                <p>
                    <input type="button" id="btnSavePost" onclick="savePost('@Model.Url')" value="保存" />
                    <a href="javascript:$('.post-edit').slideUp();$('.post-body').slideDown();" yuuko-static>取消编辑</a>
                </p>
            </div>
        }
    </div>
</div>

<div id="cmt">
    <p>
        <div id="disqus_thread" style="padding: 15px 15px 15px 15px">
            <script type="text/javascript">
                /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
                var disqus_shortname = '@ViewBag.Disqus'; // required: replace example with your forum shortname

                /* * * DON'T EDIT BELOW THIS LINE * * */
                (function () {
                    var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                    dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
                    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
                })();
            </script>
        </div>
    </p>
</div>